package com.rerun.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Created with IntelliJ IDEA.
 * Author: Dax
 * Description:
 * Date: 2017/10/1
 * Time: 11:48
 */
@EnableWebMvc
@EnableSwagger2
@Configuration
@ComponentScan(basePackages = "com.rerun")
public class SwaggerConfig {
    /**
     * Create rest api docket.
     *
     * @return the docket
     */
    @Bean
    public Docket createRestApi() {

        return new Docket(DocumentationType.SWAGGER_2)

                .apiInfo(apiInfo())

                .select()

                .apis(RequestHandlerSelectors.basePackage("com.rerun.phone"))

                .paths(PathSelectors.any())

                .build();

    }


    private ApiInfo apiInfo() {

        return new ApiInfoBuilder()
                .title("云软接口文档")
                .description("开发部")
                .termsOfServiceUrl("http://localhost:8080/")
                .version("1.0")
                .build();

    }

}
